package com.qc.sys.entity;

import com.google.common.collect.Lists;
import com.qc.common.base.BaseEntity;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

public class Role extends BaseEntity{

    /**
     * 
     */
    private String name;
    private String zhName; //中文名称
    public List<Menu> menuList = Lists.newArrayList(); // 拥有菜单列表
    private String menuIds;

    /**
     *
     * @mbggenerated 2017-10-24
     */
    public Role(String name) {
        this.name = name;
    }
    public Role(String id, String name) {
        this.id = id;
        this.name = name;
    }
    /**
     *
     * @mbggenerated 2017-10-24
     */
    public Role() {
        super();
    }


    /**
     * 
     * @return name 
     */
    public String getName() {
        return name;
    }

    /**
     * 
     * @param name 
     */
    public void setName(String name) {
        this.name = name == null ? null : name.trim();
    }

    public String getZhName() {
        return zhName;
    }

    public void setZhName(String zhName) {
        this.zhName = zhName;
    }

    public List<Menu> getMenuList() {
        return menuList;
    }

    public void setMenuList(List<Menu> menuList) {
        this.menuList = menuList;
    }

    public List<String> getMenuIdList() {
        List<String> menuIdList = Lists.newArrayList();
        for (Menu menu : menuList) {
            menuIdList.add(menu.getId());
        }
        return menuIdList;
    }

    public void setMenuIdList(List<String> menuIdList) {
        menuList = Lists.newArrayList();
        for (String menuId : menuIdList) {
            Menu menu = new Menu();
            menu.setId(menuId);
            menuList.add(menu);
        }
    }
    public String getMenuIds() {
        return StringUtils.join(getMenuIdList(), ",");
    }

    public void setMenuIds(String menuIds) {
        menuList = Lists.newArrayList();
        if (menuIds != null){
            String[] ids = StringUtils.split(menuIds, ",");
            setMenuIdList(Lists.newArrayList(ids));
        }
    }


}